#pragma once
#include <string>
namespace Umikaze::Core {

class Texture {
public:
  virtual ~Texture();

  virtual void bind(uint32_t location) = 0;

  int _width = 0;
  int _height = 0;
  uint32_t _textureId = 0;
};

class ImageTexture : public Texture {
public:
  ImageTexture(const std::string &path, bool flip = false, bool hdr = false);

  ~ImageTexture();

  virtual void bind(uint32_t location) override;

  int _channel;
  void *_data = nullptr;
};

enum DepthStencilFormat {
  DEPTH24_STENCIL8,
  DEPTH24,
  DEPTH16,
};

enum ColorFormat { RGBA8888, RG16 };
class RenderTexture : public Texture {
public:
  RenderTexture(int width, int height, ColorFormat colorFormat);

  RenderTexture(int width, int height, DepthStencilFormat depthStencilFormat);

  RenderTexture(int width, int height, int depth, ColorFormat colorFormat);

  RenderTexture(int width, int height, int depth,
                DepthStencilFormat depthStencilFormat);

  void bindAsColorAttachment(uint32_t location);
  void bindAsDepthAttachment();

  virtual void bind(uint32_t location) override;

  ColorFormat _colorFormat;
  DepthStencilFormat _depthStencilFormat;

  int _depth;

private:
  void genTexture();
  uint32_t getFormat();
};

class CubeTexture : public Texture {
public:
  //会去文件位置找
  CubeTexture(const std::string &dirPath, const std::string &suffix);
  CubeTexture(const std::string &frontPath, const std::string &backPath,
              const std::string &topPath, const std::string &bottomPath,
              const std::string &leftPath, const std::string &rightPath) {}

  ~CubeTexture();

  virtual void bind(uint32_t location) override;

  void *_faces[6] = {nullptr};

  int32_t _channel;
};

} // namespace Umikaze::Core